<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Stream Studio</title>
<script src="${cxt!}/files/easyui/jquery.min.js"></script>
<script src="${cxt!}/files/easyui/jquery.easyui.min.js"></script>
<script src="${cxt!}/files/easyui/locale/easyui-lang-zh_CN.js"></script>
<link href="${cxt!}/files/easyui/themes/icon.css" rel="stylesheet" />
<link href="${cxt!}/files/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />

<script src="${cxt!}/files/common/main.js"></script>
<script src="${cxt!}/files/common/main.css"></script>
<script type="text/javascript" src="${cxt!}/files/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">
	var index_tabs;
	var index_tabsMenu;
	var index_layout;
	
	$(function() {
		index_layout = $('#index_layout').layout({
			fit : true
		});
		
		//index_layout.layout('collapse', 'east');
	//	index_layout.layout('collapse', 'north');
		index_layout.layout('collapse', 'south');


		index_tabs = $('#tabMain').tabs({
			fit : true,
			border : false,
			onContextMenu : function(e, title) {
				e.preventDefault();
				index_tabsMenu.menu('show', {
					left : e.pageX,
					top : e.pageY
				}).data('tabTitle', title);
			},
			tools : [ {
				iconCls : 'icon-reload',
				handler : function() {
					var href = index_tabs.tabs('getSelected').panel('options').href;
					if (href) {/*说明tab是以href方式引入的目标页面*/
						var index = index_tabs.tabs('getTabIndex', index_tabs.tabs('getSelected'));
						index_tabs.tabs('getTab', index).panel('refresh');
					} else {/*说明tab是以content方式引入的目标页面*/
						var panel = index_tabs.tabs('getSelected').panel('panel');
						var frame = panel.find('iframe');
						try {
							if (frame.length > 0) {
								for ( var i = 0; i < frame.length; i++) {
									frame[i].contentWindow.document.write('');
									frame[i].contentWindow.close();
									frame[i].src = frame[i].src;
								}
								if (navigator.userAgent.indexOf("MSIE") > 0) {// IE特有回收内存方法
									try {
										CollectGarbage();
									} catch (e) {
									}
								}
							}
						} catch (e) {
						}
					}
				}
			}, {
				iconCls : 'icon-remove',
				handler : function() {
					var index = index_tabs.tabs('getTabIndex', index_tabs.tabs('getSelected'));
					var tab = index_tabs.tabs('getTab', index);
					if (tab.panel('options').closable) {
						index_tabs.tabs('close', index);
					} else {
						$.messager.alert('提示', '[' + tab.panel('options').title + ']不可以被关闭！', 'error');
					}
				}
			} ]
		});
		
		
		index_tabsMenu = $('#index_tabsMenu').menu({
			onClick : function(item) {
				var curTabTitle = $(this).data('tabTitle');
				var type = $(item.target).attr('title');

				if (type === 'refresh') {
					index_tabs.tabs('getTab', curTabTitle).panel('refresh');
					return;
				}

				if (type === 'close') {
					var t = index_tabs.tabs('getTab', curTabTitle);
					if (t.panel('options').closable) {
						index_tabs.tabs('close', curTabTitle);
					}
					return;
				}

				var allTabs = index_tabs.tabs('tabs');
				var closeTabsTitle = [];

				$.each(allTabs, function() {
					var opt = $(this).panel('options');
					if (opt.closable && opt.title != curTabTitle && type === 'closeOther') {
						closeTabsTitle.push(opt.title);
					} else if (opt.closable && type === 'closeAll') {
						closeTabsTitle.push(opt.title);
					}
				});

				for ( var i = 0; i < closeTabsTitle.length; i++) {
					index_tabs.tabs('close', closeTabsTitle[i]);
				}
			}
		});
	});

</script>


<style>
    
</style>

</head>
<body>
<div id="index_layout">
	<div data-options="region:'north'" style="height:26px;padding:2px">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'west',border:false"
				style="width:160px;padding:2px">
				测试环境
			</div>
			<div data-options="region:'east',border:false"
				style="width:160px;padding:2px">
				<% if(so.isAuthenticated()){ %> 您已经登录 <a href="/logout">退出</a> <%
				}else{ %> <a href="javascript:void(0)" onclick="doLogin()">请登录</a>
				<% } %>
			</div>
			<div data-options="region:'center',border:false" style="padding:2px">
			</div>
		</div>
	</div>
	<div data-options="region:'south'"
		style="height:26px;padding:2px;text-align:center">Stream Studio 版权所有</div>
	<div id="menu" data-options="region:'west',title:'导航菜单'"
		style="width:200px;padding:2px">
		<!--<ul>
		<% if(so.hasRole("admin")){ %>
			<li><a href="javascript:void(0)" onclick="showTab('用户管理','/user/')">用户管理</a></li>
			<li><a href="javascript:void(0)" onclick="showTab('角色管理','/role/')">角色管理</a></li>
			<li><a href="javascript:void(0)" onclick="showTab('权限管理','/permission/')">权限管理</a></li>
			<li><a href="javascript:void(0)" onclick="showTab('菜单管理','/menu/')">菜单管理</a></li>
			<li><a href="javascript:void(0)" onclick="showTab('代码管理','/code/')">代码管理</a></li>
			<li><a href="javascript:void(0)" onclick="showTab('日志管理','/syslog/')">日志管理</a></li> 
		<% } %>
		</ul>-->
	</div>
	<div data-options="region:'center',border:false">
		<div id="tabMain" class="easyui-tabs" data-options="fit:true">
				<div title="欢迎页" style="padding:20px;"></div>
		</div>
	</div>
	<div id="winLogin" class="easyui-window" title="用户登录"
		data-options="modal:true,closed:false,collapsible:false,minimizable:false,maximizable:false,closable:false,closed:true"
		style="width:400px;height:230px">
		<div style="padding:10px 60px 10px 60px">
			<form id="loginForm" action="#" method="post">
				<table cellpadding="5">
					<tr>
						<td width="80px">用户名称:</td>
						<td width="150px"><input class="easyui-textbox" type="text"
							name="username" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>用户密码:</td>
						<td><input class="easyui-textbox" type="password" name="password"
							data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>验证码:</td>
						<td><input class="easyui-textbox" type="text" name="captcha"
							data-options="required:true"></input><img id="code" src="/img"></td>
					</tr>
				</table>
			</form>
			<div style="text-align:center;padding:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-tip'" onclick="submitForm()">登录</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-clear'" onclick="clearForm()">清除</a>
			</div>
		</div>
	</div>
		<div id="win"></div>
</div>

<div id="index_tabsMenu" style="width: 120px; display: none;">
	<div title="refresh" data-options="iconCls:'transmit'">刷新</div>
	<div class="menu-sep"></div>
	<div title="close" data-options="iconCls:'delete'">关闭</div>
	<div title="closeOther" data-options="iconCls:'delete'">关闭其他</div>
	<div title="closeAll" data-options="iconCls:'delete'">关闭所有</div>
</div>

	
</body>
<script type="text/javascript">
	function doLogin() {
		$('#code').attr('src', '/img');
		$('#winLogin').window('open');
	}
	function submitForm() {
		$.post('/indexDoLogin', $('#loginForm').serialize(), function(json) {
			if (json.success) {
				$('#winLogin').window('close');
				//alert('用户登录成功');
				location.href = '/';
			} else
				alert(json.data);
		}, 'json');
	}
	function clearForm() {
		$('#loginForm').form('clear');
	}
	function showTab(title, url) {
		var tab = $('#tabMain').tabs('getTab', title);
		if (tab)
			$('#tabMain').tabs('select', title);
		else
			$('#tabMain').tabs('add', {
				title : title,
				href : url,
				closable : true
			});
	}
	
	$(document).ready(function() {
		<%if (!so.isAuthenticated()){%>
		doLogin();
		<%}%>
		
		$.get("/menu/allMenu", function(data){
				var menulist = "";
			    $.each(data, function(i, sm) {
			        menulist += "<ul>"+sm.text;
			        $.each(sm.children, function(j, o) {//<li><a href="javascript:void(0)" onclick="showTab('用户管理','/user/')">用户管理</a></li>
			            menulist += "<li><a href=\"javascript:void(0)\" onclick=\"showTab('"
			                    + o.text + "','"+ o.url + "')\">" + o.text+ "</a></li>";
			        });
			        menulist += '</ul>';
			    });
			    //alert(menulist);
				$('#menu').html(menulist);
		  });
	});
	
	
	
</script>
</html>















<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Stream Studio</title>
<script src="${cxt!}/files/easyui/jquery.min.js"></script>
<script src="${cxt!}/files/easyui/jquery.easyui.min.js"></script>
<script src="${cxt!}/files/easyui/locale/easyui-lang-zh_CN.js"></script>
<link href="${cxt!}/files/easyui/themes/icon.css" rel="stylesheet" />
<link href="${cxt!}/files/easyui/themes/bootstrap/easyui.css" rel="stylesheet" />

<script src="${cxt!}/files/common/main.js"></script>

<script type="text/javascript" src="${cxt!}/files/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		<%if (!so.isAuthenticated()){%>
			doLogin();
		<%}%>
		$.get("/menu/allMenu", function(data){
			    $.each(data, function(i, sm) {
			    	var menulist = "";
			        menulist += "<div title=\""+sm.text+"\" icon=\"icon-sys\"><ul>";
			        $.each(sm.children, function(j, o) {
			            menulist += "<li><div class=\"\"><a href=\"javascript:void(0)\" rel=\""
			            + o.url + "\"><span class=\"nav\">" + o.text+ "</span></a></div></li>";
			        });
			        menulist += '</ul></div>';
			        $('#nav').accordion('add', {
           				title : sm.text,
            			content : menulist
        			});
			    });
				//$('#nav').html(menulist);
		  });
		  
         InitLeftMenu();
	});
         function InitLeftMenu() {
             $("#nav").accordion({ animate: false });
             $('.easyui-accordion li a').click(function () {
                 var tabTitle = $(this).children('.nav').text();
                 var url = $(this).attr("rel");
                 var menuid  = $(this).children('.nav').text();
                 var s = $(this).children('span');
                 var icon = s.attr('class');
                 addTab(tabTitle, url, icon);
                 $('.easyui-accordion li div').removeClass("selected");
                 $(this).parent().addClass("selected");
             }).hover(function () {
                 $(this).parent().addClass("hover");
             }, function () {
                 $(this).parent().removeClass("hover");
             });
             //选中第一个
             $('#nav').accordion('select', 0);
         }
         function addTab(subtitle, url, icon) {
             if (!$('#tabs').tabs('exists', subtitle)) {
                 $('#tabs').tabs('add', {
                     title: subtitle,
                     content: createFrame(url),
                     closable: true,
                     icon: icon
                 });
             } else {
                 $('#tabs').tabs('select', subtitle);
                 $('#mm-tabupdate').click();
             }
             tabClose();
         }
 
         function createFrame(url) {
             var s = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
             return s;
         }
 
         function tabClose() {
             /*双击关闭TAB选项卡*/
             $(".tabs-inner").dblclick(function () {
                 var subtitle = $(this).children(".tabs-closable").text();
                 $('#tabs').tabs('close', subtitle);
             })
         }
</script>

</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
     <!--  top -->
     	<div data-options="region:'north'" style="height:26px;padding:2px">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'west',border:false"
				style="width:160px;padding:2px">
				测试环境
			</div>
			<div data-options="region:'east',border:false"
				style="width:160px;padding:2px">
				<% if(so.isAuthenticated()){ %> 您已经登录 <a href="/logout">退出</a> <%
				}else{ %> <a href="javascript:void(0)" onclick="doLogin()">请登录</a>
				<% } %>
			</div>
			<div data-options="region:'center',border:false" style="padding:2px">
			</div>
		</div>
	</div>
     <!--  left -->
     <div id="west" region="west" split="true" title="导航菜单" style="width: 180px; height: 100%">
         <div id="nav" class="easyui-accordion" fit="true" border="false">
         </div>
     </div>
     <!--  main -->
     <div id="mainPanle" region="center" style="height: 100%">
         <div id="tabs" class="easyui-tabs" fit="true" border="false">
             <div title="欢迎使用" style="padding: 20px; overflow: hidden; color: red;">
             </div>
         </div>
     </div>

	<div id="winLogin" class="easyui-window" title="用户登录"
data-options="modal:true,closed:false,collapsible:false,minimizable:false,maximizable:false,closable:false,closed:true"
		style="width:400px;height:230px">
		<div style="padding:10px 60px 10px 60px">
			<form id="loginForm" action="#" method="post">
				<table cellpadding="5">
					<tr>
						<td width="80px">用户名称:</td>
						<td width="150px"><input class="easyui-textbox" type="text"
							name="username" data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>用户密码:</td>
						<td><input class="easyui-textbox" type="password" name="password"
							data-options="required:true"></input></td>
					</tr>
					<tr>
						<td>验证码:</td>
						<td><input class="easyui-textbox" type="text" name="captcha"
							data-options="required:true"></input><img id="code" src="/img"></td>
					</tr>
				</table>
			</form>
			<div style="text-align:center;padding:5px">
				<a href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-tip'" onclick="submitForm()">登录</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					data-options="iconCls:'icon-clear'" onclick="clearForm()">清除</a>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	function doLogin() {
		$('#code').attr('src', '/img');
		$('#winLogin').window('open');
	}
	function submitForm() {
		$.post('/indexDoLogin', $('#loginForm').serialize(), function(json) {
			if (json.success) {
				$('#winLogin').window('close');
				location.href = '/';
			} else
				alert(json.data);
		}, 'json');
	}
	function clearForm() {
		$('#loginForm').form('clear');
	}
</script>
</html>